package com.af.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

public class GetSequence {
	
	
	/**
	 * 获取一个流水号
	 * @return
	 */
	public synchronized static String returnSeqNum(){
		String readLine=null;
		try {
			URL url = new URL(PropertiesManager.getInstance().returnValue("ISOMUX_URL"));
			HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
			urlConnection.setDoOutput(true);
			urlConnection.setDoInput(true);
			urlConnection.setRequestMethod("POST");
			urlConnection.setUseCaches(false);
			urlConnection.setReadTimeout(5000);
			InputStreamReader in = new InputStreamReader(urlConnection.getInputStream());
			BufferedReader buffer = new BufferedReader(in);
			readLine=buffer.readLine();
			urlConnection.disconnect();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			returnSeqNum();
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			returnSeqNum();
			e.printStackTrace();
		}
		return readLine;
	}
	
	public static void main(String[] args) {
		System.out.println(returnSeqNum());
	}
}
